package com.ysd.zytj.controller;

import java.util.ArrayList;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.ysd.zytj.dao.IStatisticsDao;
import com.ysd.zytj.vo.StatisticsVO;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

@RestController
@RequestMapping("/statistics")
@Api(tags = "数据看板")
public class StatisticsController {

	@Resource
	private IStatisticsDao statisticsDao;
	
	@ApiOperation(value = "展示数据",notes = "显示指定年份的数据")
	@PostMapping()
	public List<StatisticsVO> show(String year) {
		List<StatisticsVO> voList = new ArrayList<StatisticsVO>();
		List<Object> list = statisticsDao.findMonth(year);
		for(Object obj:list) {
			Object[] oo = (Object[]) obj;
			StatisticsVO vo = new StatisticsVO();
			vo.setMonth(oo[0].toString());
			vo.setNum(oo[1].toString());
			voList.add(vo);
		}
		return voList;
	}
}
